<script type="text/javascript">
        $(document).ready(function()
        {
            $('#btnDeleteMulti').attr('disabled',false);
            $("#btnDeleteMulti").addClass('readOnly');
            $("#actionSelect").change(function()
            {
                var selected = $(":selected", this);
                var optgroupLabel = selected.closest('option').attr('value');
                if (optgroupLabel == "")
                {
                    $('#btnDeleteMulti').attr('disabled', false);
                    $("#btnDeleteMulti").addClass('readOnly');
                } else
                {
                    $('#btnDeleteMulti').attr('disabled', false);
                    $("#btnDeleteMulti").removeClass('readOnly');
                }
            });

            $("#btnDeleteMulti").click(function() {
                if (!$("#check:checked").val()) {
                    return alertMessage();
                    return false;
                } else {
                    return ConfirmDelete();
                }
            });
        });


/*alert box*/
    function ConfirmDelete(action) {
        $("#dialogDelete").dialog({
            resizable: false,
            modal: true,
            buttons: {
                "cancel": {text: 'No',
                    class: 'buttonM bDefault',
                    click: function() {
                        $(this).dialog("close");
                        $("#actionSelect").prop("selectedIndex", 0);
                        $("#btnDeleteMulti").attr("disabled", false);
                        $("#btnDeleteMulti").addClass("readOnly");
                        return false;
                    }
                },
                "delete": {text: 'Yes',
                    class: 'buttonM bRed',
                    click: function() {
                        console.log(111111);
                        $(this).dialog("close");
                        if(action == 'multi'){
                        	$('#multidelete').submit();
                        	whileLoading();
                        } else {
                        	window.location = action;
                        	whileLoading();
                        }
                    }
                }
            }
        });
        return false;
    }
    /*general box*/
    function popupwindow(action, buttonname) {
        if(buttonname){
            btnname = buttonname;
        } else {
            btnname = '612 Confirmer';
        }
        $("#dialogAlert").dialog({
            resizable: false,
            modal: true,
            buttons: {
                "cancel": {text: 'No',
                    class: 'btn bRed buttonM',
                    click: function() {
                        $(this).dialog("close");
                        return false;
                    }
                },
                "send": {text: btnname,
                    class: 'buttonM primary summitform',
                    click: function() {
                    	if(action == true){
                    		$('.formsubmit').submit();
                    	} else {
                        	getaction();
                    	}
                    }
                }
            }
        });
        return false;
    }


    function whileLoading() {
        $("#dialogLoading").dialog({
            resizable: false,
            modal: true,
        });
        return false;
    }
    /*end alert box*/

	function multiDelete() {
		var isYes = confirm('Do you really want to delete this items?');
		if(isYes) {
			$('#multidelete').submit();
		} else {
			return false;
		}
	}
    </script>

<div id="dialogDelete" title="Are you sure do you want to delete?"
	style="display: none;">
	<p>Are you sure do you want to delete?</p>
</div>
<div id="dialogAlert" title="Cancel" style="display: none;">
	<p>Please check at least!</p>
</div>

